package base.thread_JUC2.chapter04.demo02;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class TestCase {
    public static void main(String[] args) {
        ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(5);
        for (int i = 0; i < 2; i++) {
            Task task = new Task("Task" + i);
            System.out.printf("到达一个新任务\n");
            executor.execute(task);
            System.out.printf("Server：执行器线程池大小 %d\n", executor.getPoolSize());
            System.out.printf("Server：执行器中正在执行任务的线程数 %d\n", executor.getActiveCount());
            System.out.printf("Server：已经完成的任务数 %d\n", executor.getCompletedTaskCount());
            System.out.printf("Server: 执行器接收到的任务总数: %d\n",executor.getTaskCount());
        }
        executor.shutdown();
    }
}
